home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / PROGRAMMING / DESKLIBC / SOURCES.ZIP / DeskLib / !DLSources / Libraries / Dialog / c / Wait4Click < prev   
Text File  |  1994-03-13  |  2KB  |  70 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Dialog.Wait4Click.c
  12.     Author:  Copyright © 1993 Tim Browse and Jason Williams
  13.     Version: 1.00 (10 Jul 1993)
  14.     Purpose: Very high level window (dialogue) handling -
  15.              Processing events for dialogue windows
  16. */
  17.  
  18.  
  19. #include "DeskLib:Wimp.h"
  20. #include "DeskLib:WimpSWIs.h"
  21.  
  22. #include "DeskLib:Dialog.h"
  23. #include "DeskLib:Event.h"
  24.  
  25.  
  26. extern icon_handle Dialog_WaitForClick(dialog dbox)
  27. /*  Wait for choice to be made by the user, or for the window to close.
  28.  *  If user closes window by clicking outside, dialog_CLOSE is returned, else
  29.  *  the icon which was clicked is returned.
  30.  *  This function may be called repeatedly while you wait for a particular
  31.  *  icon to be clicked.
  32.  *
  33.  *  Some care is taken to ensure that the 'dbox->lastchoice' value will
  34.  *  always be a valid icon handle except when no icns have yet been clicked.
  35.  *  (i.e. if you click icon 3, then close the window, lastchoice will be 3
  36.  *  while this function will return dialog_CLOSE)
  37.  */
  38. {
  39.   window_state wstate;
  40.   icon_handle  choice, lastchoice;
  41.  
  42.   lastchoice = dbox->lastclicked;
  43.   dbox->lastclicked = choice = dialog_NOCHOICE;
  44.  
  45.   do
  46.   {
  47.     Event_Poll();
  48.     
  49.     /*  If user has clicked outside window, hit return, or clicked the close
  50.      *  box, causing it to close, we take that as a 'Cancel': dialog_CLOSE.
  51.      */
  52.     Wimp_GetWindowState(dbox->window, &wstate);
  53.     if (wstate.flags.data.open)                /* Window has not been closed */
  54.       choice = dbox->lastclicked;
  55.     else
  56.     {
  57.       choice = dialog_CLOSE;
  58.       dbox->state.persist = FALSE;
  59.       dbox->state.stillopen =FALSE;
  60.     }
  61.  
  62.   } while (choice == dialog_NOCHOICE);    /* Repeat until close or click     */
  63.  
  64.   if (dbox->lastclicked < 0)              /* Ensure return last clicked icon */
  65.     dbox->lastclicked = lastchoice;       /* when window is closed etc       */
  66.  
  67.   return(choice);
  68. }
  69.  
  70.